package com.llk.rabbitmqlearn.consumer;

import com.llk.rabbitmqlearn.config.RabbitConfig;
import com.llk.rabbitmqlearn.utils.DateUtils;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 延迟队列消费者
 */
@Slf4j
@Component
public class TtlConsumer {

    @RabbitListener(queues = RabbitConfig.DEAD_QUEUE)
    public void receiveDead(Message message, Channel channel) throws Exception {
        String msg = new String(message.getBody());
        log.info("当前时间：{},收到死信队列信息{}", DateUtils.getDateStr(new Date(), DateUtils.FORMAT_PATTERN), msg);
    }
}
